package stu.day39_day.day40;

import java.util.Arrays;
import java.util.Scanner;

public class hw2 {

    public static int dp(int[][] arr){

        int len =arr.length;
        int[] dp = new int[len];
        Arrays.fill(dp,1);
        int max = 0;
        for(int i=1;i<len;i++){
            for(int j=0;j<i;j++){
                if(arr[i][1]>arr[j][1]){
                    dp[i] = Math.max(dp[i],dp[j]+1);
                }
            }
            max = Math.max(max,dp[i]);
        }
        return max;


    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] str  = sc.nextLine().split(",");

        int len = str.length/2;
        int[][] arr = new int[len][2];
        for (int i = 0; i < len; i++) {
            arr[i][0] = Integer.parseInt(str[2*i]);
            arr[i][1] = Integer.parseInt(str[2*i+1]);
        }

        Arrays.sort(arr,(a,b)-> a[0]==b[0]?b[1]-a[1]:a[0]-b[0] );
        System.out.println(dp(arr));

    }
}